﻿#ifndef GLOBAL_H
#define GLOBAL_H

#include <QLabel>
#include <QDateTime>
#include <QPixmap>
#include <QStackedLayout>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QStandardItemModel>
#include <QDataWidgetMapper>
#include <QSqlQueryModel>
#include <QTimer>
#include <QDebug>
#include <QDir>
#include "shareMemory.h"
#include "countdowntime.h"
#include "KeyBoard.h"
#include "Scrolllabel.h"
#include "FileIO.h"
#include "MyThread.h"
#include "Define.h"
#include "database/database.h"



struct Labeltree{
    QLineEdit* Edit;
    QPushButton* Bind;
    QPushButton* UnBind;
};
typedef struct
{
    unsigned char offset;
    QString exp;
}YX_ERR_WARN;
struct Gun_Current_State{
    unsigned char Gun_Num;//枪号
    QString m_QrCodeNum;//此枪二维码
//    int Link_State;//此枪连接状态等于0为已连接
//    int State;//此枪状态,故障状态大于0,枪未检测到状态-1,正常状态0
    int Page;//此枪当前显示页面
    uint CountDownisActivity[9];//此参数给所有有倒计时界面的对象修改,所有页面的倒计时状态,初始所有倒计时状态都为60,一共九个每支枪分离的倒计时页面
    int VINflag;
};
struct Choose_Gun_Frame_Color{
    QFrame *Frame;
    QLabel *Label_0;
    QLabel *Label_1;
    QPushButton *PushButton;
};

extern Gun_Current_State GUN_STATE[GUN_AMOUNT];
extern QStackedLayout* stackLayout;//栈布局
extern chargpile_data* chargingData;//共享内存数据
extern KeyBoard *dlg;
extern MyThread mt;
extern RefreshGun Refreash_Thread[GUN_AMOUNT];
extern rf_card* card;
extern int focus_gun_;

void onErrorInfo(QLabel *TextEdit, int Error_Num);
rf_card* initCard(rf_card* card);
void Init_Focus();
void Back_Stand_By();
void AsciiToHex(char * pAscii, unsigned char * pHex, int nLen);
void HexToAscii(unsigned char * pHex, unsigned char * pAscii, int nLen);
QString onGunQRCodeInfo(QString gunCode,int gunCode_, int m_num, int gunNum);
void onStartingCharging(int m_num, char m_mode, char m_state, char m_checkResult, int m_value, char m_guntab, char VINState);


//extern YX_ERR_WARN yxerr_tab[];


enum Page{
           WaitUsePage = 0, /*0待机*/
           SystemSetting1Page,/*1系统设置1的界面*/
           SystemSetting2Page,/*2系统设置2的界面*/
           SystemSetting3Page,/*3系统设置3的界面*/
           SystemSetting4Page,/*4系统设置4的界面*/
           chargeCardManageInfoPage,/*5充电卡管理信息界面*/
           recordOfChargePage,/*6充电记录浏览*/
           filterRecordOfChargePage,/*7充电记录筛选*/
           warningInfoPage,/*8告警信息查询*/
           exportRecordOfChargePage,/*9导出充电记录*/
           cardVertifyPage,/*10请输入卡号和密码*/
           chargeTypePage,/*11充电类型*/
           settingOfChargeMoneyPage,/*12充电金额设置p*/
           settingOfChargePowerPage,/*13充电电量设置*/
           settingOfChargeTimePage,/*14充电时长设置*/
           deviceMaintaiceforLogingPage,/*15设置维护登录界面*/
           warnningDetailInfoPage,/*16详细告警内容界面*/
           chargeSubscribePage,/*17预约界面*/
           chargeWatchingDCPage,/*18直流计费界面*/
           chargeWatchingACPage,/*19交流计费界面*/
           settleAccountPage,/*20结算界面*/
           returnChargeGunPage,/*21归还抢界面*/
           endOfChargeVerifyPage,/*22输入验证码界面*/
           chargeGunNotConnectPage,/*23充电枪未连接界面*/
           chargeGunNotNotConnectPage,/*24充电枪未可靠连接界面*/
           cardAndQRCodeVerifyPage,/*25刷卡扫码界面*/
           equipmentMaintaincePage,/*26维护界面*/
           equipmentUpgradePage,/*27升级界面*/
           WaitSwipCardPage,/*28请刷充电管理卡*/
           netDetailInfoPage,/*29网络详情*/
           ChooseGunPage,/*30选择枪号界面*/
           OutstandingOrderPage,/*31未完成订单界面*/
           GuninfoSettingPage,/*32枪信息设置界面*/
           ChangeguninfoPage,/*33修改枪信息界面*/
           SetRatePage,/*34设置分时段费率界面*/
          };
enum SwipFlag{
    ReferBindedAdministrationCard = 0,//查询充电管理卡是否已绑定
    BindA1 = 1,
    BindA2 = 2,
    BindB1 = 3,
    BindB2 = 4,
    BindB3 = 5,
    UnBindA1 = 6,
    UnBindA2 = 7,
    UnBindB1 = 8,
    UnBindB2 = 9,
    UnBindB3 = 10,
};
enum DC_FaultNum{
    DC_IND_OTHER_FAULT = 1,//其他故障
    DC_IND_EMERSTOP_FAULT = 4,//急停按钮动作故障
    DC_IND_SMOKE_ALARM = 5, //烟感故障
    DC_IND_AC_BREAKER = 6,//交流输入断路器故障
    DC_IND_DC_OUT_CONTACTOR = 7,//直流母线输出接触器拒动/误动故障
    DC_IND_DC_OUT_FUSES = 8,//直流母线输出熔断器故障
    DC_IND_INTERFACE_ELE_LOCK_FAULT = 9,//充电接口电子
    DC_IND_CHARGE_FAN_FAULT = 10,//充电桩风扇故障
    DC_IND_THUNDERBOLT = 11,//避雷器故障
    DC_IND_INSULATION = 12,//绝缘监测故障
    DC_IND_BATTERY_REVERSE = 13,//电池极性反接故障
    DC_IND_CHARGING_CAR_GUIDE = 14,//电池极性反接故障
    DC_IND_PILE_OVERTURNED = 15,//充电桩过温故障
    DC_IND_GUNS_OVERTURNED = 16,//充电接口过温故障
    DC_IND_GUNS_NO_HOMELESS = 17,//充电枪未归位告警
    DC_IND_BMS_COMMUNICATION = 18,//BMS 通信故障
    DC_IND_INPUT_V_OVER = 19,//输入电压过压故障
    DC_IND_INPUT_V_UNDER = 20,//输入电压欠压故障
    DC_IND_DC_BUS_OUT_V_OVER = 21,//直流母线输出过压故障
    DC_IND_DC_BUS_OUT_V_UNDER = 22,//直流母线输出欠压故障
    DC_IND_DC_BUS_OUT_A_OVER = 23,//直流母线输出过流故障
    DC_IND_CHARGE_MODULE = 24,//充电模块故障
    DC_IND_MODULE_AC_INPUT = 25,//充电模块交流输入故障
    DC_IND_MODULE_AC_IN_V_OVER = 26,//充电模块交流输入过压故障
    DC_IND_MODULE_AC_IN_V_UNDER = 27,//充电模块交流输入欠压故障
    DC_IND_MODULE_AC_IN_PHASE = 28,//充电模块交流输入缺相故障
    DC_IND_MODULE_DC_OUT_SHORT = 29,//充电模块直流输出短路故障
    DC_IND_MODULE_DC_OUT_A_OVER = 30,//充电模块直流输出过流故障
    DC_IND_MODULE_DC_OUT_V_OVER = 31,//充电模块直流输出过压故障
    DC_IND_MODULE_DC_OUT_V_UNDER = 32,//充电模块直流输出欠压故障
    DC_IND_MODULE_OVERTURNED = 33,//充电模块过温故障
    DC_IND_MODULE_COMMUNICATION = 34,//充电模块通信故障
    DC_IND_MODULE_FAN = 35, //充电模块风扇故障
    DC_IND_CONNECT_CAR = 36,//车辆连接状态
    DC_IND_GUNS_STATUS = 37,//充电桩充电枪座状态
    DC_IND_ELE_LOCK_STATUS = 38,//充电接口电子锁状态
    DC_IND_DC_OUT_CONTACTOR_STATUS = 39,//直流输出接触器状态
    DC_IND_PRIVATE_WARN_NUM = 40,//私有告警编号
    DC_IND_PRIVATE_VALUE = 41,//私有告警数值
    DC_IND_DOOR_FAULT = 42,//门禁故障
    DC_IND_DC_BUS_OUT_CONTACTOR_ADHESION_FAULT = 43,//直流输出接触器粘连故障
    DC_IND_INSULATION_WARN = 44,//绝缘监测告警
    DC_IND_DISCHARGE_LOOP_WARN = 45,//泄放回路故障
    DC_IND_CHARGE_PILE_OVERTURNED_WARN = 46,//充电桩过温告警
    DC_IND_CHARGE_GUN_OVERTURNED_WARN = 47,//充电枪过温告警
    DC_IND_AC_IN_CONTACTOR_ERR_ACTION = 48,//交流输入接触器据动/误动故
    DC_IND_AC_IN_CONTACTOR_ADHESION_FAULT = 49,//交流输入接触器粘连故障
    DC_IND_ASSIST_POWER_FAULT = 50,//辅助电源故障
    DC_IND_PARALLEL_CONTACTOR_ERR_ACTION = 51,//并联接触器据动/误动故障
    DC_IND_PARALLEL_CONTACTOR_ADHESION_FAULT = 52,//并联接触器粘连故障
    DC_IND_CAN_COMMUNICATION_FAULT = 100,
    DC_IND_AMMATER_FAULT = 101,//电表故障
    DC_IND_CARD_READER_FAULT = 102,//读卡器故障
};
enum Gun_Current_State_CountDownTime{
    CountDownTime_ChargeTypePage = 0,
    CountDownTime_SettingOfChargeMoney = 1,
    CountDownTime_SettingOfChargePower = 2,
    CountDownTime_SettingOfChargeTime = 3,
    CountDownTime_SettleAccount = 4,
    CountDownTime_CarVertify = 5,
    CountDownTime_ChargeGunNotNotConnct = 6,
    CountDownTime_EndOfChargeVerify = 7,//输入验证码的界面倒计时
    CountDownTime_ReturnChargeGun = 8,
};

#endif // GLOBAL_H
